package com.demo.security.cloud.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.demo.security.cloud.entity.TUser;
import com.demo.security.cloud.mapper.TUserMapper;
import com.demo.security.cloud.service.ITUserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * @author liyan
 * @since 2020-06-17 13:12:33
 * @describe 服务实现类
 */
@Service("userService")
public class TUserServiceImpl extends ServiceImpl<TUserMapper, TUser> implements ITUserService {

    @Override
    public TUser getUserByUserName(String userName) {

        LambdaQueryWrapper<TUser> lambdaQuery = Wrappers.lambdaQuery();
        lambdaQuery.eq(!StringUtils.isEmpty(userName), TUser::getUserName, userName);
        // 查不到就返回空，由provider抛出异常
        return this.getOne(lambdaQuery);
    }

}
